<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
<%@ include file="/common/common-css.jsp"%>
<style>
#jquery-table td {
	cursor: pointer !important
}
.load_bg {
	background: #000;
	opacity: 0.1;
	left: 0px;
	top: 0px;
	position: fixed;
	height: 100%;
	width: 100%;
	overflow: hidden;
	z-index: 10000;
}

.load_img {
	left: 50%;
	top: 180px;
	position: fixed;
	height: 50px;
	overflow: hidden;
	z-index: 20000;
}
</style>
</head>
<body class="no-skin">
	<div class="load_bg" style="display: none;"></div>
	<img src="http://img.xmiles.cn/commentloading.gif" class="load_img"
		style="display: none" />
	<div class="page-content">
		<div class="page-header"
			style="margin-bottom: 0px; padding-bottom: 10px;"></div>

		<form id="queryForm">
			<div class="page-content-area">
				<div class="row">
					<div class="col-sm-12">
						<div class="widget-box"
							style="border: 0px solid #ccc; border-top: none; border-bottom: none;">
							<div class="widget-header widget-header-blue widget-header-flat">
								<h4 class="widget-title">选择条件进行查询</h4>
								<div class="widget-toolbar">
									<a href="#" data-action="collapse"> <i
										class="ace-icon fa fa-chevron-up"></i>
									</a>
								</div>
							</div>
							<div class=" widget-body">
								<div class="widget-main">
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">平台:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select class="form-control" name="platform">
												<option value="">全部</option>
												<option value="0">通用</option>
												<option value="android">安卓</option>
												<option value="ios">ios</option>
											</select>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-3 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">产品</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select id="prdid" name="prdid" class="form-control"></select>
										</div>
									</div>

									<div class="form-group col-xs-12 col-sm-3 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">渠道</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select id="channel" name="channel"></select>
										</div>
									</div>

									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">手机号:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<input type="text" style="padding-left: 0px" name="mobnum"
												id="mobnum">
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">真实姓名:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<input type="text" style="padding-left: 0px" name="petname"
												id="petname">
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">身份证号:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<input type="text" style="padding-left: 0px" name="idcard"
												id="idcard">
										</div>
									</div>
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">性别:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select class="form-control" name="sex">
												<option value="">不限</option>
												<option value="先生">先生</option>
												<option value="女士">女士</option>
											</select>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">居住城市:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<input type="text" style="padding-left: 0px" name="city"
												id="city">
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">身份:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select class="form-control" name="profession">
												<option value="">不限</option>
												<option value="上班族">上班族</option>
												<option value="学生">学生</option>
												<option value="个体户">个体户</option>
												<option value="自由职业">自由职业</option>
												<option value="企业主">企业主</option>
												<option value="其它">其它</option>
											</select>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">信用卡:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select class="form-control" id="credit" name="credit">
												<option value="">不限</option>
												<option value="有">有</option>
												<option value="没有">没有</option>
											</select>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">芝麻信用:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<div class="input-daterange input-group">
												<input type="text" style="padding-left: 0px; width: 109px;"
													name="start_sesame_point" id="start_sesame_point">
												<span class="input-group-addon" style="width: 6px"> <i
													class="fa fa-exchange"></i>
												</span> <input type="text" style="padding-left: 0px; width: 109px;"
													name="end_sesame_point" id="end_sesame_point">
											</div>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">淘宝购物:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select class="form-control" id="taobao_shops" name="taobao_shops">
												<option value="">不限</option>
												<option value="0次">0次</option>
												<option value="1-3次">1-3次</option>
												<option value="大于3次">大于3次</option>
											</select>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">月收入:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<div class="input-daterange input-group">
												<input type="text" style="padding-left: 0px;width: 109px;"
													name="start_income" id="start_income"> <span
													class="input-group-addon" style="width: 6px;"> <i
													class="fa fa-exchange"></i>
												</span> <input type="text" style="padding-left: 0px;width: 109px;"
													name="end_income" id="end_income">
											</div>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">学历:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select class="form-control" id="education" name="education">
												<option value="">不限</option>
												<option value="中专及以下">中专及以下</option>
												<option value="中专">中专</option>
												<option value="大专">大专</option>
												<option value="本科">本科</option>
											</select>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label" style="text-align: right"
											for="sex">注册时间:</label>
										<div class="col-sm-8" style="padding-left: 0px">
										    <div class="input-daterange input-group">
												<input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="createStartTime" name="createStartTime"> 
												 <span class="input-group-addon" style="width: 6px"> 
												    <i class="fa fa-exchange"></i>
												 </span>
												 <input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="createEndTime" name="createEndTime">
											 </div>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label" style="text-align: right"
											for="sex">最后打开时间:</label>
										<div class="col-sm-8" style="padding-left: 0px">
										    <div class="input-daterange input-group">
												<input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="lastOpenStartTime" name="lastOpenStartTime"> 
												 <span class="input-group-addon" style="width: 6px"> 
												    <i class="fa fa-exchange"></i>
												 </span>
												 <input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="lastOpenEndTime" name="lastOpenEndTime">
											 </div>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3" style="clear: both;">
										<label class="col-sm-4 control-label" style="text-align: right"
											for="sex">新增资料时间:</label>
										<div class="col-sm-8" style="padding-left: 0px">
										    <div class="input-daterange input-group">
												<input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="startTime" name="startTime"> 
												 <span class="input-group-addon" style="width: 6px"> 
												    <i class="fa fa-exchange"></i>
												 </span>
												 <input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="endTime" name="endTime">
											 </div>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label" style="text-align: right"
											for="sex">更新资料时间:</label>
										<div class="col-sm-8" style="padding-left: 0px">
										    <div class="input-daterange input-group">
												<input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="updateStartTime" name="updateStartTime"> 
												 <span class="input-group-addon" style="width: 6px"> 
												    <i class="fa fa-exchange"></i>
												 </span>
												 <input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="updateEndTime" name="updateEndTime">
											 </div>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">查询类型:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select class="form-control" id="optype" name="optype">
												<option value="1">按注册用户</option>
												<option value="2" selected>按测额度用户</option>
											</select>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="col-md-12 center">
						<div class="clearfix form-actions">
							<button class="btn btn-purple  no-border" type="button"
								name="btn-query" onclick="query_any()" id="btn-query">
								<i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
								查询
							</button>
							&nbsp;&nbsp;&nbsp;
					        <button class="btn btn-grey  no-border" type="reset">
						     <i class="ace-icon fa fa-undo icon-on-right bigger-110"></i>
						              重置
					         </button>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
					   <a href="javascript:void(0)" class="btn btn-success btn-small"
					      id="output" onclick="loadlist()">导出列表</a>
						<table id="jquery-table"
							class="table table-striped table-bordered table-hover">
						</table>
					</div>
				</div>
			</div>
		</form>
	</div>

	<%@ include file="/common/common-js.jsp"%>
	<script type="text/javascript" src="${ctx}/js/call_func.js"></script>
	<script type="text/javascript" src="${ctx}/ace/js/jquery.dataTables.min.js"></script>
	
	<script type="text/javascript">
	
		function loadlist() {
			var form = document.forms["queryForm"];
			form.action = ctx + "/loanuser/exportData.action";
			form.submit();
		}
		
		var souceList = null;
		//【查询】按钮Click事件
		function query_any() {
			$(".load_bg").removeAttr("style");
			$(".load_img").removeAttr("style");
			if (jqTable != null) {
				jqTable.fnDraw();
			} else {
				loaddata();
			}
			$("#output").show();
		}
		var jqTable = null;
		var loaddata = function() {
			jQuery(function($) {
				jqTable = $('#jquery-table').dataTable(
						{
							//数据列控制（包括对应返回JSON属性名称，对应表头列索引位置、数据转换封装等）
							"columnDefs" : [

							{
								"title" : '平台',
								"name" : "platform",
								"data" : "platform",
								"targets" : [ 0 ],
								"bSortable" : false,
							}, 
							{
								"title" : '产品',
								"name" : "prdid",
								"data" : "prdid",
								"targets" : [ 1 ],
								"bSortable" : false,
								"render" : function(value, type, row) { // 返回自定义内容
									switch (value) {
									case "8000":
										var temp = "菠萝贷主包";
										break;
									case "8001":
										var temp = "极速借钱";
										break;
									case "8002":
										var temp = "菠萝贷ios";
										break;
									case "8003":
										var temp = "手机现金侠";
										break;
									case "8004":
										var temp = "借了么";
										break;
									case "8005":
										var temp = "菠萝贷ios新";
										break;
									case "8006":
										var temp = "联登外部页";
										break;
									case "8100":
										var temp = "微信菠萝贷";
										break;
									case "8200":
										var temp = "香蕉还卡主包";
										break;
									case "8300":
										var temp = "速来贷";
										break;
									default :
										var temp = "--";
									    break;
									}
									return temp;
								}
							},

							{
								"title" : "渠道",
								"name" : "channel_name",
								"data" : "channel_name",
								"targets" : [ 2 ],
								"bSortable" : false,
							}, 
							{
								"title" : "贷款金额",
								"name" : "amount",
								"data" : "amount",
								"targets" : [ 3 ],
								"bSortable" : false,
							}, 
							{
								"title" : "注册时间",
								"name" : "regdate",
								"data" : "regdate",
								"targets" : [ 4 ],
								"bSortable" : false,
							}, 
							{
								"title" : "最后一次打开时间",
								"name" : "lastopendate",
								"data" : "lastopendate",
								"targets" : [ 5 ],
								"bSortable" : false,
								"render" : function(value, type, row) { // 返回自定义内容
									if (value == null) {
										return "--";
									} else {
										return value;
									}
								}
							},

							{
								"title" : "新增资料时间",
								"name" : "createtime",
								"data" : "createtime",
								"targets" : [ 6 ],
								"bSortable" : true,
							},

							{
								"title" : "更新资料时间",
								"name" : "updatetime",
								"data" : "updatetime",
								"targets" : [ 7 ],
								"bSortable" : true,
							}, 
							{
								"title" : "用户ID",
								"name" : "userid",
								"data" : "userid",
								"targets" : [ 8 ],
								"bSortable" : false,
							}, 
							{
								"title" : "手机号码",
								"name" : "mobnum",
								"data" : "mobnum",
								"targets" : [ 9 ],
								"bSortable" : false,
							}, 
							{
								"title" : "真实姓名",
								"name" : "petname",
								"data" : "petname",
								"targets" : [ 10 ],
								"bSortable" : false,
							}, 
							{
								"title" : "性别",
								"name" : "sex",
								"data" : "sex",
								"targets" : [ 11 ],
								"bSortable" : false,
								"width" : "5%",
							}, 
							{
								"title" : "身份证号",
								"name" : "idcard",
								"data" : "idcard",
								"targets" : [ 12 ],
								"bSortable" : false,
							}, 
							{
								"title" : "居住城市",
								"name" : "city",
								"data" : "city",
								"targets" : [ 13 ],
								"bSortable" : false,
							}, 
							{
								"title" : "职业身份",
								"name" : "profession",
								"data" : "profession",
								"targets" : [ 14 ],
								"bSortable" : false,
							}, 
							{
								"title" : "信用卡",
								"name" : "credit",
								"data" : "credit",
								"targets" : [ 15 ],
								"bSortable" : false,
								"render" : function(value, type, row) { // 返回自定义内容
									if (value == null) {
										return "--";
									} else {
										return value;
									}
								}
							}, 
							{
								"title" : "芝麻信用",
								"name" : "sesame_point",
								"data" : "sesame_point",
								"targets" : [ 16 ],
								"bSortable" : false,
							}, 
							{
								"title" : "淘宝购物",
								"name" : "taobao_shops",
								"data" : "taobao_shops",
								"targets" : [ 17 ],
								"bSortable" : false,
								"render" : function(value, type, row) { // 返回自定义内容
									if (value == null) {
										return "--";
									} else {
										return value;
									}
								}
							}, 
							{
								"title" : "收入",
								"name" : "income",
								"data" : "income",
								"targets" : [ 18 ],
								"bSortable" : false,
								"render" : function(value, type, row) { // 返回自定义内容
									if (value == null) {
										return "--";
									} else {
										return value;
									}
								}
							}, 
							{
								"title" : "学历",
								"name" : "education",
								"data" : "education",
								"targets" : [ 19 ],
								"bSortable" : false,
								"render" : function(value, type, row) { // 返回自定义内容
									if (value == null) {
										return "--";
									} else {
										return value;
									}
								}
							}, ],
							"sAjaxSource" : ctx + "/loanuser/list.action",
							"fnServerData" : function(sSource, aoData,
									fnCallback) {//从服务器请求数据
								var data = $('#queryForm').serializeObject();
								data.aoData = JSON.stringify(aoData);
								//alert(sSource);
								$.ajax({
									"dataType" : 'json',
									"type" : "POST",
									"url" : sSource,
									"data" : data,
									"success" : function(resp) {
										$(".load_bg").attr("style",
												"display:none");
										$(".load_img").attr("style",
												"display:none");
										$("#hidden_pass").attr("style",
												"display:block");
										$('#jquery-table').removeClass(
												"dataTable");
										fnCallback(resp);
										initListPage();
									},
									"error" : function(XMLHttpRequest,
											textStatus, errorThrown) {
										$(".load_bg").attr("style",
												"display:none");
										$(".load_img").attr("style",
												"display:none");
										alert('请求服务器错误,请刷新重试！！'); //错误提示，包括服务器重启导致的session失效
									}
								});
							},
							"fnRowCallback" : function(nRow, aData,
									iDisplayIndex, iDisplayIndexFull) {
							},
							"bDestroy" : true,
							"bScrollInfinite" : true,
							"sScrollXInner" : "100%",
							"sScrollY" : "100%",//如果不设置，IE会有问题
							"aaSorting" : [ [ 0, "desc" ] ]
						//初始化加载，默认按第几列排序、排序方式（列从0开始计算）
						});
			});
		}

		function initDate() {
			var today = GetDateStr(0);
			// var beforedate = GetDateStr(-5);
			if ($.isBlank($("#startTime").val())) {
				jQuery("#startTime").val(today);
			}
			if ($.isBlank($("#endTime").val())) {
				jQuery("#endTime").val(today);
			}
		}

		function GetDateStr(AddDayCount) {
			var dd = new Date();
			dd.setDate(dd.getDate() + AddDayCount);//获取AddDayCount天后的日期
			var y = dd.getFullYear();
			var m = dd.getMonth() + 1;//获取当前月份的日期
			var d = dd.getDate();
			return y + "-" + m + "-" + d;
		}

		//时间控件
		jQuery(function($) {
			$(".date-picker").datepicker({
				autoclose : true
			}).next().on(ace.click_event, function() {
				$(this).prev().focus();
			});
		});

		$(document).ready(function() {
			// query_any();
			initDate();
			loadChannel();
			loadProduct();
			$("#channel").combobox();
			$("#output").hide();
		});
	</script>
</body>
</html>